/**
 * 系统登录
 */
import utils from "service/utils";
import fetch from "service/fetch";
/* ============================== */
let baseurl = "./web/api/index.php?r=";
if (process.env.NODE_ENV !== "production") {
  //baseurl = '//h5.wufae.com/Pingan/womentest/web/api/index.php?r=dev-';
}
if (window.location.origin.indexOf("wufae") > -1) {
}
/* ========================== */
//$.get(baseurl+'sview');
/* ========================== */
var wxConfigUrl = baseurl + "jssdk";
export default {
  getCode(data) {
    return fetch(baseurl + "getCode", { type: "post", data: data });
  },
  saveData(data) {
    return fetch(baseurl + "saveData", { type: "post", data: data });
  },
  getInit(data) {
    let callback = window.location.href;
    return fetch(baseurl + "getInit", {
      type: "get",
      data: { callback: callback },
    }).then(function (res) {
      if (res.status != 1) {
        window.location.href = res.url;
        return false;
      }
      return res;
    });
  },
  getWxSign(data) {
    return fetch(
      "//v-test.wufae.com/wfapi/wechat/jssdk?url=" +
        encodeURIComponent(location.href.split("#")[0]),
      { type: "get" }
    ).then(function (res) {
      let config = res.data || {};
      config.debug = false;
      //config.jsApiList = ['onMenuShareTimeline', 'onMenuShareAppMessage'];
      config.jsApiList = [
        "onMenuShareTimeline",
        "onMenuShareAppMessage",
        "onMenuShareQQ",
      ];
      wx.config(config);
      utils.initShareFunc();
    });
  },
};
